/*
package org.itboys.core.service.mongo.front;

import org.itboys.commons.ErrorException;
import org.itboys.commons.utils.tools.ListUtil;
import org.itboys.core.common.SundayCommonConstants;
import org.itboys.core.entity.mongo.SundayKnowledgeBase;
import org.itboys.mongodb.core.MongoDataSource;
import org.itboys.mongodb.service.BaseMongoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

*/
/**
 * Auther: 罗尧坤
 * Date: 2018/8/3
 * Description: 知识库_小程序_服务类
 *//*

@Service
public class SundayFrontKnowledgeBaseService extends BaseMongoService<SundayKnowledgeBase> {
    @Resource(name = "mobileDs")
    private MongoDataSource mobileDataSource;
    @Override
    protected MongoDataSource getMongoDataSource() {
        return mobileDataSource;
    }

    @Override
    protected Class<SundayKnowledgeBase> getEntityClass() {
        return SundayKnowledgeBase.class;
    }

    */
/**
     * 分页获取所有知识库
     * @param request
     * @return
     *//*

    public List<SundayKnowledgeBase> select(HttpServletRequest request){
        Map<String, Object> param = new HashMap<>();
        param.put("sort","ct");
        param.put("order","desc");
        param.put("isDeleted", 0);
        //未停用的知识库
        param.put("status", SundayCommonConstants.NO);

        List<SundayKnowledgeBase> list = super.pageQuery(request,param).getData();
        return list;
    }

    */
/**
     * 查询单个知识库
     * @param id
     * @return
     *//*

    public SundayKnowledgeBase getDetail(Long id){
        Map<String, Object> param = new HashMap<>();
        param.put("isDeleted", SundayCommonConstants.NO);
//        param.put("status",SundayCommonConstants.YES);
        param.put("id", id);

        //查出单个数据, 加入判断
        List<SundayKnowledgeBase> list =  super.list(param);
        if (ListUtil.isNotNull(list)){
            if (list.get(0).getStatus() == SundayCommonConstants.NO){
                SundayKnowledgeBase knowledgeBase = list.get(0);
                //小程序端访问一次, 访问次数+1
                knowledgeBase.setHits(knowledgeBase.getHits()+1);
                super.updateExceptEmpty(id, knowledgeBase);
                return knowledgeBase;
            }else {
                throw new ErrorException("该知识库已停用");
            }
        }else {
            throw new ErrorException("未找到该知识库");
        }
    }

}
*/
